import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.SaveMode;
import org.apache.spark.sql.SparkSession;

public class SparkSql {
    public static void main(String[] args) {
        SparkSession spark = SparkSession.builder()
                .appName("RDDToDataset")
                .master("local[*]")
                .getOrCreate();

        String db = "";
        String table = "";
        String sql = "";
        Dataset df = spark.sql(sql);

        df.show();

        df.write()
                .mode(SaveMode.Overwrite)
                .saveAsTable(db + "." + table);
    }
}
